﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Refugees.Views.Windows
{
    /// <summary>
    /// Логика взаимодействия для Personals.xaml
    /// </summary>
    public partial class Personals : Window
    {
        Repositories.UserRepository userRepository = new Repositories.UserRepository();
        public Personals()
        {
            InitializeComponent();
            if (Repositories.UserRepository.User.role_id != 3)
            {
                User.Visibility = Visibility.Hidden;
            }
            PersonalItems.ItemsSource = userRepository.Personals();
        }

        private void EditPersonal(object sender, RoutedEventArgs e)
        {
            var personalData = (sender as Button).DataContext as Models.PersonalData;
            if (personalData != null)
            {
                new PersonalData(personalData).Show();
                Close();
            }
        }

        private void BackClick(object sender, RoutedEventArgs e)
        {
            new About().Show();
            Close();
        }

        private void AddPersonal(object sender, RoutedEventArgs e)
        {
            new PersonalData().Show();
            Close();
        }

        private void EnterClick(object sender, RoutedEventArgs e)
        {
            var personalData = (sender as Button).DataContext as Models.PersonalData;
            if (personalData != null)
            {
                Repositories.ModelRepository.PersonalData = personalData;
                MessageBox.Show("Данные для услуги выбраны");
            }
        }

        private void UserClick(object sender, RoutedEventArgs e)
        {
            new UserAdmin().Show();
            Close();
        }
    }
}
